package com.hkts.management.pay.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.management.common.utils.CustomPage;
import com.hkts.management.common.utils.Result;
import com.hkts.management.common.utils.ResultUtil;
import com.hkts.management.pay.entity.HktsPayRecord;
import com.hkts.management.pay.service.IHktsPayRecordService;
import com.hkts.management.utils.CustomPageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yck
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/order/hktsPayRecord")
@Api(tags = "信息费交易记录接口")
public class HktsPayRecordController {


    @Autowired
    public IHktsPayRecordService iHktsPayRecordService;

    /**
     * 分页查询数据
     *
     * @param page          分页信息
     * @param hktsPayRecord 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getHktsPayRecordPageList")
    @ApiOperation(value = "交易记录分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页", dataType = "int",required = true),
            @ApiImplicitParam(name = "size", value = "每页条数", dataType = "int",required = true),
            @ApiImplicitParam(name = "orderId", value = "运单id", dataType = "string",required = true),
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "string",required = true),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "string",required = true),
            @ApiImplicitParam(name = "driverName", value = "司机姓名", dataType = "string",required = true)
    })
    public Result<CustomPage<HktsPayRecord>> getHktsPayRecordPageList(Page<HktsPayRecord> page, HktsPayRecord hktsPayRecord) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iHktsPayRecordService.selectPage(page, hktsPayRecord)));
    }

    /**
     * 保存和修改公用的
     *
     * @param hktsPayRecord 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsPayRecordSave")
    public Result<Object> hktsPayRecordSave(HktsPayRecord hktsPayRecord) {
        iHktsPayRecordService.saveOrUpdate(hktsPayRecord);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/hktsPayRecordGetById")
    public Result<Object> hktsPayRecordGetById(String id) {
        HktsPayRecord byId = iHktsPayRecordService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsPayRecordDelete")
    public Result<Object> hontUserDelete(String id) {
        iHktsPayRecordService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsPayRecordBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iHktsPayRecordService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }

}
